package com.ecfront.dao.impl;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.GoodsBrandDAO;
import com.ecfront.pojo.GoodsBrand;

/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class GoodsBrandDAOImpl extends HibernateDaoSupport implements GoodsBrandDAO {

	protected void initDao() {}


	public void save(GoodsBrand transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(GoodsBrand persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public GoodsBrand findById(java.lang.Integer id) {
			GoodsBrand instance = (GoodsBrand) getHibernateTemplate().get(
					"com.ecfront.pojo.GoodsBrand", id);
			return instance;
	}


	public List findByProperty(String propertyName, Object value) {
		String queryString = "from GoodsBrand as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findByGbName(Object gbName) {
		return findByProperty(NAME, gbName);
	}

	public List findAll() {
		String queryString = "from GoodsBrand";
		return getHibernateTemplate().find(queryString);

	}

	public static GoodsBrandDAO getFromApplicationContext(ApplicationContext ctx) {
		return (GoodsBrandDAO) ctx.getBean("GoodsBrandDAO");
	}
}